import request from '@/utils/request'

/**
 * 获取课程列表
 * @param {*} params  {department_id：1，course_name:"",page:1,limit:20}
 * @returns
 */
export const httpCourseList = (params) => {
  return request({
    url: '/study/query-course-list',
    method: 'get',
    params,
  })
}

// 获取所有院系
export const httpAllDepts = (data) => {
  return request({
    url: `/study/search-all-departments`,
    method: 'post',
    data,
  })
}

// 知识图谱
export const httpKnowledgeChart = (params) => {
  return request({
    url: '/study/graph-data',
    method: 'get',
    params,
  })
}
/**
 * 查询节点所有关系
 * @param {*} params {course_id:1,node_id:1}
 * @returns
 */
export const httpNodeRelations = (params) => {
  return request({
    url: '/study/node-relationships',
    method: 'get',
    params,
  })
}

/**
 * 查询课程下的资料列表
 * @param {*} params {course_id，department_id，page:1,limit:20}
 * @returns
 */
export const httpCourseData = (params) => {
  return request({
    url: `/study/search-course-data`,
    method: 'get',
    params,
  })
}

/**
 * 获取资料详情
 * @param {*} data  {document_id:1}
 * @returns
 */
export const httpDataDetail = (data) => {
  return request({
    url: `/study/information-viewing`,
    method: 'post',
    data,
  })
}
/**
 * 获取关键词列表
 * @param {*} params {document_id:1,course_id:1,keyword_name:"",limit:6}params
 * @returns
 */
export const httpKeywords = (params) => {
  return request({
    url: `/study/search-keywords`,
    method: 'get',
    params,
  })
}

/**
 * 刷题
 * @param {*} params  {page:1,limit:20,keyword_id:1}
 * @returns
 */
export const httpExamQuestions = (params) => {
  return request({
    url: `/study/search_questions`,
    method: 'get',
    params,
  })
}
/**
 * 最后一题记录
 * @param {*} params
 * @returns
 */
export const httpLastRecord = (params) => {
  return request({
    url: `/study/user-question-record-search`,
    method: 'get',
    params,
  })
}
/**
 * 刷题记录
 * @param {*} params
 * @returns
 */
export const httpExamRecords = (params) => {
  return request({
    url: `/study/search_questions_data`,
    method: 'get',
    params,
  })
}
/**
 * 刷题 参考资料
 * @param {*} params  {course_id :1,department_id :1,node_id :2,page:1,limit:20}
 * @returns
 */
export const httpRefers = (params) => {
  return request({
    url: `/study/keyword-document-search`,
    method: 'get',
    params,
  })
}

/**
 * 答题
 * @param {*} data {
  "question_id": 1,
  "user_answer": "A",
  "keyword_id": 1,
  "page": 1,
  "limit": 1,
  "index": 1
}
 * @returns 
 */
export const httpReplyQuestion = (data) => {
  return request({
    url: `/study/user-answer-question`,
    method: 'post',
    data,
  })
}
/**
 * 资料推荐
 * @param {*} data
 * @returns
 */
export const httpRecommends = (data) => {
  return request({
    url: `/study/user-data-recommend`,
    method: 'post',
    data,
  })
}

/**
 * 收藏或者加入到错题本
 * @param {*} data {
  "question_id": 1,
  "type": 1
}
 * @returns
 */
export const httpCollectOrAddError = (data) => {
  return request({
    url: `/study/user-question-collection-add`,
    method: 'post',
    data,
  })
}
/**
 * 取消：收藏或者加入到错题本
 * @param {*} data {
  "question_id": 1,
  "type": 1
}
 * @returns
 */
export const httpRemoveCollectOrError = (data) => {
  return request({
    url: `/study/user-question-collection-del`,
    method: 'post',
    data,
  })
}

/**
 * 获取试题收藏 或者错题本列表
 * @param {*} params  {type:1,page:1,limit:20}
 * @returns
 */
export const httpQsCollectOrError = (params) => {
  return request({
    url: `/study/user-question-collection-search`,
    method: 'get',
    params,
  })
}
/**
 * 一键删除 收藏或者错题本
 * @param {*} params  {type:1}类型：1收藏本，2错题本
 * @returns
 */
export const httpRemoveAllCollectError = (params) => {
  return request({
    url: `/study/user-question-collection-del-all`,
    method: 'get',
    params,
  })
}
/**
 * 易错题
 * @param {*} params
 * @returns
 */
export const httpEasyErrorQuestions = (params) => {
  return request({
    url: `/study/easy-mistake-question-search`,
    method: 'get',
    params,
  })
}
/**
 * 收藏 错题本 易错题 统计
 * @param {*} params
 * @returns
 */
export const httpCollectEasyErrorCount = () => {
  return request({
    url: `/study/user-question-collection-count`,
    method: 'get',
  })
}
